package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class Level3Activity extends Level2Activity {

    public void checkVictory() {
        View leftStar = findViewById(R.id.left_star);
        View rightStar = findViewById(R.id.right_star);
        View middleStar = findViewById(R.id.middle_star);
        View farRightStar = findViewById(R.id.far_right_star);
        View farLeftStar = findViewById(R.id.far_left_star);
        if (leftStar.getVisibility() == View.INVISIBLE  && rightStar.getVisibility() == View.INVISIBLE  && middleStar.getVisibility() == View.INVISIBLE  && farRightStar.getVisibility() == View.INVISIBLE  && farLeftStar.getVisibility() == View.INVISIBLE) {
            Toast.makeText(this, "Congratulations! Your face is moist! You win!", Toast.LENGTH_LONG).show();

            startActivity(new Intent(this, CongratulationsActivity.class));
        }
    }

    public void onLeftButtonPush(View view) {
        Log.d("Yourface", "THE LEFT BUTTON IS BEING PUSHED!!!!!!!!!!!!!!!!!!!!!!!!!!");
        toggleVisibility(R.id.left_star);
        toggleVisibility(R.id.middle_star);
        toggleVisibility(R.id.far_right_star);
        checkVictory();
    }

    public void onMiddleButtonPush(View view) {
        Log.d("Yourface", "THE MIDDLE BUTTON IS BEING PUSHED!!!!!!!!!!!!!!!!!!!!!!!!");
        toggleVisibility(R.id.middle_star);
        toggleVisibility(R.id.left_star);
        checkVictory();
    }

    public void onRightButtonPush(View view) {
        Log.d("Yourface", "THE RIGHT BUTTON IS BEING PUSHED!!!!!!!!!!!!!!!!!!!!!!!!");
        toggleVisibility(R.id.right_star);
        toggleVisibility(R.id.left_star);
        checkVictory();
    }

    public void onFarRightButtonPush(View view) {
        Log.d("Yourface", "THE RIGHT BUTTON IS BEING PUSHED!!!!!!!!!!!!!!!!!!!!!!!!");
        toggleVisibility(R.id.far_right_star);
        toggleVisibility(R.id.left_star);
        checkVictory();
    }

    public void onFarLeftButtonPush(View view) {
        Log.d("Yourface", "THE RIGHT BUTTON IS BEING PUSHED!!!!!!!!!!!!!!!!!!!!!!!!");
        toggleVisibility(R.id.far_left_star);
        toggleVisibility(R.id.left_star);
        checkVictory();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level3);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level3, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
